import 'dart:math';

class Point {
  var x, y;
  // Point (a, b) {x = a; y = b;}
  Point (this.x, this.y);

  // 根据一个比例系数，来缩放 坐标的大小；
  Point scale (factor) => Point(x * factor, y * factor);

  Point operator +(p) => Point(x + p.x, y + p.y);

  static double distance (p1, p2) {
    var dx = p1.x - p2.x;
    var dy = p1.y - p2.y;

    return sqrt(dx * dx + dy * dy);
  }
}

void runPoint () {
  var point = Point(1, 2);
  var point2 = Point(3, 4);

  var p2 = point.scale(2);

  print('${point.x} : ${point.y}');
  print('${p2.x} : ${p2.y}');

  var y = (point + point2).y;
  print('y : ${y}');

  var dis = Point.distance(point2, point);
  print('dis : ${dis}');

}
